package com.bps.zzant.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.bps.zzant.model.OrderGarment;
import com.bps.zzant.model.Payment;
@Repository
public class PaymentDAOImpl implements PaymentDAO {
	@Autowired
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public List<Payment> getPaymentsByOrderId(int orderId) {
		List<Payment> payments = getSessionFactory().getCurrentSession().createCriteria(Payment.class).add(Restrictions.eq("order.orderId", orderId)).addOrder(Order.asc("paymentDate")).list();
		return payments;
	}

}
